package org.styx.seata.tcc.storage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.styx.seata.tcc.storage.domain.Storage;

@Mapper
public interface StorageMapper extends BaseMapper<Storage> {

    /**
     * 扣减库存
     */
    void decrease(@Param("productId") Long productId, @Param("count") Integer count);

    /**
     * 冻结库存
     * @param productId
     * @param residue
     * @param frozen
     */
    void updateFrozen(@Param("productId")Long productId,
                      @Param("residue")Integer residue,
                      @Param("frozen")Integer frozen);

    /**
     * 提交时，把冻结量修改到已售出
     * @param productId
     * @param count
     */
    void updateFrozenToUsed(@Param("productId")Long productId,
                            @Param("count")Integer count);


    /**
     * 回滚时，把冻结量修改到可用库存
     * @param productId
     * @param count
     */
    void updateFrozenToResidue(@Param("productId")Long productId,@Param(
            "count")Integer count);

}
